﻿namespace Main.lib.space
{

    /**
     * Three-dimensional space class
     * 
     * @author  Bruno Miguel de Oliveira Tamer <bmotamer@gmail.com>
     * @version 2011.11.25
     * 
     * @brief   Let you create a "lightweight" three-dimensional array
     * @param   Generic container type
     */
    public sealed class Ambient<T>
    {

        public readonly uint Width, Height, Depth; // Dimensions
        public readonly T[]  Data;                 // Container

        /**
         * Constructor
         * 
         * @brief Creates the container
         * @param Width
         * @param Height
         * @param Depth
         */
        public Ambient(uint width, uint height, uint depth)
        {
            Width  = width;
            Height = height;
            Depth  = depth;
            Data   = new T[Depth * Height * Width];
        }

        /**
         * Container accessor
         * 
         * @brief Let you get or set a position's value
         * @param X-coordinate
         * @param Y-coordinate
         * @param Z-coordinate
         */
        public T this[uint x, uint y, uint z]
        {
            get
            {
                return Data[x + (y + z * Height) * Width];
            }
            set
            {
                Data[x + (y + z * Height) * Width] = value;
            }
        }

    }

}